<?php 
require_once 'Emp.service.class.php';
$empservice=new Empservice();

if(!empty($_REQUEST['flag'])){
    if($_REQUEST['flag']=="del"){
    $id=$_GET['id'];
    $res=$empservice->delEmpById($id);
    if($res==1){
        header("Location:ok.php");
    }else{
        header("Location:error.php");
        }
    }else if($_REQUEST['flag']=="addEmp"){
        $name=$_REQUEST['name'];
        $grade=$_REQUEST['grade'];
        $email=$_REQUEST['email'];
        $salary=$_REQUEST['salary'];
        $res=$empservice->addEmp($name, $grade, $email, $salary);
        if($res==1){
            header("Location:ok.php");
        }else{
            header("Location:error.php");
        }
    }else if($_REQUEST['flag']=="updateEmp"){
        $id=$_REQUEST['id'];
        $name=$_REQUEST['name'];
        $grade=$_REQUEST['grade'];
        $email=$_REQUEST['email'];
        $salary=$_REQUEST['salary'];
        $res=$empservice->updateEmp($id,$name, $grade, $email, $salary);
        if($res==1){
            header("Location:ok.php");
        }else{
            header("Location:error.php");
        }
    }
}
?>